package P1200;

import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-08 18:36
 */
public class P1200_你的飞碟在这儿 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(convert(scanner.nextLine())==convert(scanner.nextLine())?"GO":"STAY");
        scanner.close();
    }

    private static int convert(String s){
        int res = 1;
        char[] chars = s.toCharArray();
        for(char c:chars){
            res *= c-'A'+1;
        }
        return res%47;
    }
}
